package com.xk857.school.controller;


import com.xk857.entities.Courier;
import com.xk857.school.req.CourierREQ;
import com.xk857.school.req.HelpPeopleREQ;
import com.xk857.school.service.ICourierService;
import com.xk857.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 代取快递 前端控制器
 * </p>
 *
 * @author CV大魔王
 * @since 2021-05-02
 */
@Api(value = "快递代拿管理接口", tags = "快递代拿管理接口")
@RestController
@RequestMapping("/pri/courier")
public class CourierController {

    @Autowired
    private ICourierService courierService;

    @ApiOperation("帮取快递")
    @PutMapping("/help")
    public Result helpByPeople(@RequestBody HelpPeopleREQ req) {
        return courierService.helpByPeople(req.getId(),req.getPeopleId(),req.getPeopleRemark());
    }


    @ApiOperation("添加快递代拿信息")
    @PostMapping
    public Result add(@RequestBody Courier courier) {
        return courierService.add(courier);
    }


    @ApiOperation("修改快递代拿信息")
    @PutMapping
    public Result update(@RequestBody Courier courier) {
        return courierService.update(courier);
    }


    @ApiOperation("删除快递代拿信息")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable String id) {
        return courierService.delete(id);
    }

    @ApiOperation("快递代取完成")
    @PutMapping("/complete/{id}")
    public Result complete(@PathVariable String id) {
        return courierService.complete(id);
    }

    @ApiOperation("条件分页查询")
    @PostMapping("/search")
    public Result search(@RequestBody CourierREQ req) {
        return courierService.searchPage(req);
    }
}
